﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using AspNetCs.Common;
using AspNetCs.Bll;

public partial class CustomerSeviceList : BasePage
{
    private int pageSize = 20;
    protected int recodCount = 0;
    protected int ClassId = 0;
    private int province = 0;
    private int city = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        DnsRequest.UrlRequestAgentName(out city, out province);

        if (!IsPostBack)
        {
            ClassId = StringHelper.isNumber_int(Request["ArticleClass"]);
            ViewState["ClassId"] = ClassId;
            BindReapter();
        }
        else
        { 
            if(ViewState["ClassId"]!=null)
            {
                ClassId = StringHelper.isNumber_int(ViewState["ClassId"].ToString());
            }
        }
    }


    public void BindReapter()
    {
        string cmdText = "select ArticleId,Title,IsTop,IsCommend,UpdateTime,Hits from Article where ClassId={0} order by IsTop desc,Hits desc";
        cmdText = string.Format(cmdText, ClassId);
        DataPagesOperate operate = new DataPagesOperate();
        AspNetPager1.PageSize = pageSize;
        operate.BindRepeater(cmdText, AspNetPager1, "IsTop desc,Hits desc", "ArticleId", rptList, out recodCount);

    }
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        BindReapter();
    }
    protected void rptList_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Footer)
        {
            if (rptList.Items.Count <= 0)
            {
                Panel pl = e.Item.FindControl("Pl_Nothing") as Panel;
                pl.Visible = true;
            }
        }
    }

    public override string UI_TopControl()
    {

        return base.UI_TopControl(true, city, province);
    }
    public override string UI_Head()
    {
        return base.UI_Head(configInfo.SiteTitle, configInfo.Meta_Keywords, configInfo.Meta_Description, city, province);
    }
}
